//vue生命周期
export default{
  mounted(el,binding) {
    console.log(el,binding,'-----------')
    const observer = new IntersectionObserver((entries)=>{
        entries.forEach(entry=>{
            entry
            if(entry.isIntersecting){
                console.log('----------')
                const img = binding.value;
                img.onload = ()=>{
                    el.src = img.src;
                }
                observer.unobserve(el);
               
            }
        })
    })
    el._lazy_observer = observer
    observer.observe(el)
  },
  beforeUnmount(el){
  if(el._lazy_observer){
    el._lazy_observer.unobserve(el);
    delete el._lazy_observer;
  }}}
